<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('终端划拨记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 120px">品牌名称：</label>
                                <select name="manuNum" >
                                    <option value="">选择品牌</option>
                                    <option th:each="m:${manufacturer}" th:text="${m.MANU_NAME}" th:value="${m.MANU_NUM}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px">活动编号：</label>
                                <input type="text" name="actId"/>
                            </li>
                            <li>
                                <label style="width: 120px">活动名称：</label>
                                <input type="text" name="actName"/>
                            </li>
                            <li>
                                <label style="width: 120px;">达标阶段：</label>
                                <select name="achievementStage" th:with="type=${@dict.getType('stage')}">
                                    <option value="">请选择</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px">服务商编号：</label>
                                <input type="text" name="agentNum" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"/>
                            </li>
                            <li>
                                <label style="width: 120px">服务商名称：</label>
                                <input type="text" name="agentName"/>
                            </li>
                            <li>
                                <label style="width: 120px">返现服务商编号：</label>
                                <input type="text" name="return_agentId" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"/>
                            </li>
                            <li>
                                <label style="width: 120px">商户编号：</label>
                                <input type="text" name="merchantNumber" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"/>
                            </li>
                            <li>
                                <label style="width: 120px;">返现类型：</label>
                                <select name="type">
                                    <option value="">所有</option>
                                    <option value="0">交易达标</option>
                                    <option value="3">盟主</option>
                                    <option value="4">团长</option>
                                    <option value="5">业务员</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">终端类型：</label>
                                <select name="posType" th:with="type=${@dict.getType('terminal_type')}">
                                    <option value="">请选择</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px">结算人名：</label>
                                <input type="text" name="screenName"/>
                            </li>
                            <li>
                                <label style="width: 120px">出款流水号：</label>
                                <input type="text" name="settle_serial"/>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px">SN号段：</label>
                                <input type="text" name="startSn"/>
                                <span>-</span>
                                <input type="text" name="endSn"/>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px">POS号段：</label>
                                <input type="text" name="startPos" oninput="value=value.replace(/[^0-9]/g,'')"/>
                                <span>-</span>
                                <input type="text" name="endPos" oninput="value=value.replace(/[^0-9]/g,'')"/>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px">达标时间：</label>
                                <input type="text" name="startDate" id="startTime" class="time-input" readonly/>
                                <span>-</span>
                                <input type="text" name="endDate" id="endTime" class="time-input" readonly/>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px">返现时间：</label>
                                <input type="text" name="startDate1"  class="time-input" readonly/>
                                <span>-</span>
                                <input type="text" name="endDate1"   class="time-input" readonly/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 search-collapse">
                <span style="color:blue">[</span>
                <span style="color: blue;font-style: initial">返现总金额：</span>
                <span id="returnMoney" style="color: red;font-style: initial">0</span><span style="color: blue;font-style: initial"> 元</span>
                <span style="color:blue">]</span>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="exportExcel()" >
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"  class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "terminal/section";

        var terminalTypeDatas = [[${@dict.getType('terminal_type')}]];

        var stageDatas = [[${@dict.getType('stage')}]];


        $(function() {
            var options = {
                url: prefix + "/listSections",
                exportUrl: prefix + "/export",
                modalName: "达标返现明细",
                responseHandler:responseHandler,
                columns: [
                {
                    field: 'SETTLE_SERIAL',
                    title: '出款流水号'
                },
                {
                    field: 'POSNO',
                    title: '终端号'
                },
                {
                    field: 'SN',
                    title: 'SN编号'
                },
                {
                    field: 'ACT_ID',
                    title: '活动编号'
                },
                {
                    field: 'ACT_NAME',
                    title: '活动名称'
                },
                {
                    field: 'CREATEDATE',
                    title: '开通时间'
                },
                {
                    field: 'ACHIEVEMENT_DATE',
                    title: '达标时间'
                },
                {
                    field: 'ACHIEVEMENT_STAGE',
                    title: '达标阶段',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(stageDatas, value);
                    }
                },
                {
                    field: 'RETURN_MONEY',
                    title: '返现金额'
                },
                {
                    field: 'RETURN_DATE',
                    title: '返现时间'
                },
                {
                    field: 'TYPE',
                    title: '返现类型',
                    formatter: function(value,row,index){
                        if (value == 0){
                            return "<span style='color: blue'>交易达标</span>";
                        } else if (value == 3){
                            return "<span style='color: red'>盟主</span>";
                        } if (value == 4){
                            return "<span style='color: #00B83F'>团长</span>";
                        } if (value == 5){
                            return "<span style='color: #00B83F'>业务员</span>";
                        } else {
                            return "<span style='color: darkgrey'>暂无</span>";
                        }
                    }
                },
                {
                    field: 'POS_TYPE',
                    title: '终端类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(terminalTypeDatas, value);
                    }
                },
                {
                    field: 'MERNO',
                    title: '商户编号'
                },
                {
                    field: 'SCREEN_NAME',
                    title: '结算人'
                },
                {
                    field: 'DIRECTLY_UNDER_AGENTNO',
                    title: '服务商编号'
                },
                {
                    field: 'AGENT_NAME',
                    title: '服务商名称'
                },
                {
                    field: 'RETURN_AGENTID',
                    title: '返现对象编号'
                },
                {
                    field: 'RETURN_AGENTNAME',
                    title: '返现对象名称'
                },
                /*{
                    field: 'NUM_NAME',
                    title: '所属资深总监编号',
                    formatter: function(value,row,index){
                     /!*   var split = value.split(",");
                        return split[0];*!/
                        return value;
                    }
                },
                {
                    field: 'NUM_NAME',
                    title: '所属资深总监名称',
                    formatter: function(value,row,index){
                       /!* var split = value.split(",");
                        return split[1];*!/
                        return value;
                    }
                },*/
               /* {
                    field: 'PRO_YL_ID',
                    title: '采购人奖励团长编号'
                },
                {
                    field: 'PRO_YL_NAME',
                    title: '采购人奖励团长名称'
                },
                {
                    field: 'PRO_AGENT_NUM',
                    title: '采购人奖励服务商编号'
                },
                {
                    field: 'PRO_AGENT_NAME',
                    title: '采购人奖励服务商名称'
                }*/
                ]
            };
            $.table.init(options);
        });
        // 导出数据
        function exportExcel(formId) {
            table.set();
            $.modal.confirm("确定导出达标返现明细吗？", function() {
                var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
                var params = $("#" + table.options.id).bootstrapTable('getOptions');
                var dataParam = $("#" + currentId).serializeArray();
                dataParam.push({ "name": "orderByColumn", "value": params.sortName });
                dataParam.push({ "name": "isAsc", "value": params.sortOrder });
                $.modal.loading("正在导出数据，请稍后...");
                $.post(table.options.exportUrl, dataParam, function(result) {
                    if (result.code == web_status.SUCCESS) {
                        $.modal.alertSuccess(result.msg);
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                });
            });
        }

        function responseHandler(res) {
            $("#returnMoney").text($.common.isEmpty(res.data) ? 0 : res.data.RETURN_MONEY);
        }

    </script>
</body>
</html>
